package com.gome.boot.config.mq.annotation;

import com.gome.boot.config.mq.rocketmq.MQConstants;
import com.gome.boot.config.mq.rocketmq.SerializeType;
import org.springframework.stereotype.Component;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
 * RocketMQ消息消费者配置注解.
 *
 * @author baoxiufeng
 */
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.ANNOTATION_TYPE, ElementType.TYPE})
@Component
public @interface RocketMQ {

    String value() default "";

    String group() default MQConstants.DIAMOND_GROUP_ROCKETMQ_SERVER;

    String dataId() default MQConstants.DIAMOND_DATAID_ROCKETMQ_SERVER;

    /**
     * 当isDiamondKey为true时，topic和tag代表获取topic或tag值所使用的diamondKey.
     * 当isDiamondKey为false时，topic和tag代表实际的topic或tag值.
     * 考虑到不变性原则，尽量采用diamondKey来获取实际的topic或tag值.
     */
    boolean isDiamondKey() default true;

    String topic() default MQConstants.DEFAULT_TOPIC;

    String tag() default "*";

    boolean orderly() default false;

    SerializeType serializeType() default SerializeType.FASTJSON;
}
